<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../../css/common.css" media="all">

	</head>

	<style type="text/css">
		.layui-table th {
			position: relative;
			min-height: 20px;
			height: 35px;
			line-height: 20px;
			font-size: 14px;
			padding: 0px 0px;
		}

		.layui-table td {
			position: relative;
			min-height: 20px;
			height: 100%;
			line-height: 14px;
			font-size: 14px;
			padding: 0px 0px;
		}

		.layui-input,
		.layui-textarea {
			display: block;
			width: 100%;
			padding: 0px 0px;
			border: 0px;
		}

		.layui-input {
			text-align: center;
		}
	</style>

	<body>
		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form id="form" class="layui-form test_edit" lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-form-item">
							<label class="layui-form-label">
								<!-- 活动时间 -->
								<!-- <span style="color:red">*</span> -->
							</label>
							<div class="layui-input-inline"
								style="display: flex;align-items: center;height: 2.375rem;padding: 0.5625rem 0;width: 350px;">
								<!-- <input type="text" name="dates" lay-verify="required" disabled placeholder="请选择" autocomplete="on" class="layui-input limited_name"> -->
								<span style="white-space: nowrap;">活动名称:</span>
								<span id="name"></span>
								<input type="hidden" name="seckill_id" lay-verify="required" placeholder=""
									autocomplete="off" class="layui-input seckill_id">
								<!-- <span style="white-space: nowrap;margin-left: 30px;">佣金模板:</span> -->
							</div>
							<div class="layui-form-mid layui-word-aux">
								<span>佣金模板:</span>
								<div class="layui-inline">
									<select id="select" style="border: 1px solid #000;" lay-filter="level">
										<option id="selectOp" value="">请选择一个佣金模板</option>
									</select>
								</div>
								<button type="button" class="layui-btn layui-btn-sm" onclick="resetNum()">重新计算</button>
								<!-- <select id="select" lay-filter="level">
								  <option id="selectOp" value="">请选择一个佣金模板</option>
								</select> -->
								<!-- 	<button type="button" class="layui-btn layui-btn-sm" style="display: inline-block;">重新计算</button> -->
								<!-- <button type="button" class="layui-btn layui-btn-sm" onclick="opentemp()">选择模板</button> -->
								<!-- <a href="Javascript:;" onclick="searchdata('market_id')">选择</a> -->
							</div>
						</div>
						<div class="layui-card-body">
							<table class="layui-table" id="testtable">
								<!-- <table class="layui-table" lay-size="sm"> -->
								<colgroup>
									<col>
									<col>
									<col>
									<col>
									<col>
								</colgroup>

								<thead>
									<tr>
										<th></th>
										<th style="width: 100px;">商品编号</th>
										<th style="width: 250px;">商品名</th>
										<th style="width: 70px;">成本价</th>
										<th style="width: 70px;">会员价</th>
										<!-- <th>原抵扣积分zhu</th> -->
										<th style="width: 70px;">团购价</th>
										<!-- <th>积分比例%zhu</th> -->
										<!-- <th>积分使用zhu</th> -->
										<th style="width: 70px;">补贴</th>
										<th style="width: 70px;">团人数</th>
										<th style="width: 70px;">中奖人数</th>
										<th style="width: 120px;">显示已参团人数</th>

										<th style="width: 70px;">活动数量</th>
										<th style="width: 120px;">显示已购数量</th>
										<th style="width: 70px;">购买上限</th>
										<th style="width: 70px;">显示数量</th>

										<th style="width: 60px;">团时长</th>
										<th style="width: 90px;">发起佣金</th>
										<th style="width: 90px;">直推佣金</th>
										<th style="width: 90px;">间推佣金</th>
										<th style="width: 90px;">团长佣金</th>
										<th style="width: 90px;">管理奖</th>
										<th style="width: 100px;">合伙人佣金</th>
										<th style="width: 100px;">服务站佣金</th>
										<th style="width: 40px;">排序</th>
									</tr>
								</thead>

								<tbody id="temp">
									<tr>
										<td></td>
										<td style="width: 100px;">
											<div class="flex">
												<!-- <input class="layui-input layui-input-choose" onfocus="choosedata()" name="" value="zhu" /> -->
												<button type="button" class="layui-btn layui-btn-sm"
													onclick="choosedata()"><i
														class="layui-icon layui-icon-search"></i></button>
											</div>
										</td>
										<td style="width: 250px;"></td>
										<td style="width: 70px;"></td>
										<td style="width: 70px;"></td>
										<td style="width: 70px;"></td>
										<td style="width: 70px;"></td>
										<td style="width: 70px;"></td>
										<td style="width: 70px;"></td>
										<td style="width: 120px;"></td>
										<td style="width: 70px;"></td>
										<td style="width: 120px;"></td>

										<td style="width: 70px;"></td>
										<td style="width: 70px;"></td>
										<td style="width: 60px;"></td>
										<td style="width: 90px;"></td>
										<td style="width: 90px;"></td>
										<td style="width: 90px;"></td>
										<td style="width: 90px;"></td>
										<td style="width: 90px;"></td>
										<td style="width: 100px;"></td>
										<td style="width: 100px;"></td>
										<td style="width: 40px;"></td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>

				</form>
			</div>
		</div>
		<script src="../../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../../js/jquery.min.js"></script>
		<script src="../../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../../js/common.js"></script>
		<script>
			var _data = {}
			var tempObj = {}

			function child(data, index) {
				$(" input[name=seckill_id]").val(data.seckill_id);
				$(" input[name=dates]").val(data.name);
				let nameEl = document.getElementById('name')
				nameEl.innerHTML = data.name
			}
			layui.config({
				base: '../../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'table'], function() {
				var $ = layui.$,
					admin = layui.admin,
					form = layui.form;
				table = layui.table;
				// 监听选择模板
				form.on('select(level)', function(data) {
					if (data.value !== "") {
						console.log(data.value)
						window.tempList.forEach(item => {
							if (data.value === item.id) {
								tempObj = item
							}
						})
					} else if (data.value === "") {
						tempObj = {}
					}
				})


				$("button[type=reset]").on("click", function() {
					_data = {}
					tempObj = {}
					document.getElementById("form").reset();
				});


				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data = Object.assign(_data, data);
					var request_data = [];
					var testtable = document.getElementById('testtable');
					console.log(testtable, 'testtable')
					// console.log(testtable.rows.length);
					var rows = testtable.rows;
					console.log(rows.length, '90000')
					for (var i = 0; i < rows.length; i++) {
						var cells = rows[i].cells;
						var skuid = $(cells).find('input[name=skuid]').val(),
							price = $(cells).find('input[name=price]').val(), //团购价格
							stock = $(cells).find('input[name=stock]').val(), //库存数量
							sales = $(cells).find('input[name=sales]').val(), //已购买数量
							num = $(cells).find('input[name=num]').val(), //显示数量


							//score = $(cells).find('input[name=score]').val(),
							//score_scale = $(cells).find('input[name=score_scale]').val(), 

							top_count = $(cells).find('input[name=top_count]').val(), //购买上限

							subsidy = $(cells).find('input[name=subsidy]').val(), //补贴

							group_num = $(cells).find('input[name=group_num]').val(), //团人数
							group_wnum = $(cells).find('input[name=group_wnum]').val(), //中奖人数
							group_onum = $(cells).find('input[name=group_onum]').val(), //显示团参与人数

							duration = $(cells).find('input[name=duration]').val(),
							launch_fee = $(cells).find('input[name=launch_fee]').val(),
							leader_fee = $(cells).find('input[name=leader_fee]').val(), // 团长佣金
							direct_fee = $(cells).find('input[name=direct_fee]').val(), // 直推奖励
							indirect_fee = $(cells).find('input[name=indirect_fee]').val(),
							/* 间推奖励 */
							team_fee = $(cells).find('input[name=team_fee]').val(), // 团队奖励 === 管理奖
							copartner_fee = $(cells).find('input[name=copartner_fee]').val(), // 合伙人奖励
							station_fee = $(cells).find('input[name=station_fee]').val(), // 服务站奖励

							oid = $(cells).find('input[name=oid]').val();
						console.log(skuid, 'id')
						if (skuid) {
							request_data.push({
								'skuid': skuid,
								'price': price,

								'subsidy': subsidy,
								'group_num': group_num,
								'group_wnum': group_wnum,
								'group_onum': group_onum,

								'stock': stock,
								'num': num,
								//'score' : score,
								//'score_scale' : score_scale, 
								'top_count': top_count,
								'sales': sales,
								'duration': duration,
								'launch_fee': launch_fee,
								'leader_fee': leader_fee,
								'direct_fee': direct_fee,
								'indirect_fee': indirect_fee,
								'team_fee': team_fee,
								'copartner_fee': copartner_fee,
								'station_fee': station_fee,
								'oid': oid
							})
						}
					}

					_data.request_data = JSON.stringify(request_data)
					console.log(request_data, '000000')
					console.log(JSON.stringify(_data));

					layer.confirm('确定要提交数据？', function() {
						loading();
						if (_data.id) {
							//submitdata(server.limited_goods_add);
						} else {
							delete _data.id
							submitdata(server.seckill_goods_add);
						}
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});


				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.closeAll('loading')
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});
				}
				window.tempList = []
				// 获取模板数据
				// window.getTempLate()
				getTempLate = function() {
					$.post(server.shop_feetemp_list, {}, function(res, status) {
						if (res.code === 0) {
							let data = res.seckill_fee_temp.data;
							window.tempList = data
							let html = '';
							for (var i = 0; i < data.length; i++) {
								html += `<option value="${data[i].id}">${data[i].name}</option>`
							}
							$("#selectOp").after(html)
							form.render();
						}
					})
				}
				getTempLate()


				window.getdata = function(data, name, id) {
					var html;
					var a = 1;
					for (var i = 0; i < data.length; i++) {
						html += '<tr>' +
							`<td id="code${data[i].skuid}">` + (a + i) + '</td>' +
							'<td><div class="flex"><input  class="layui-input"  name="skuid" value=' + data[i]
							.skuid + ' /></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="skuname" value=' + (data[i]
								.skuname ? data[i].skuname : "") + '></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="price_member" value=' + data[i]
							.price_member + ' /></div></td>' +
							//'<td><div class="flex"><input  class="layui-input"  name="score_old" lay-verify="required" value="' + (data[i].score?data[i].score:'0')+ '"/></div></td>' +

							// `<td><div class="flex"><input onkeyup="inputChange(this, data[i])"  class="layui-input" name="price" lay-verify="required" value="' + (data[i].limit_price?data[i].limit_price:'')+ '"/></div></td>` +
							`<td><div class="flex"><input class="layui-input" name="price" lay-verify="required" value="${data[i].limit_price?data[i].limit_price:''}" /></div></td>` +
							//							'<td><div class="flex"><input  class="layui-input"  name="score_scale" lay-verify="required" /></div></td>' +
							//'<td><div class="flex"><input  class="layui-input"  name="score" lay-verify="required" /></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="subsidy" lay-verify="required" /></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="group_num" lay-verify="required" /></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="group_num" lay-verify="required" /></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="group_wnum" lay-verify="required" /></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="group_onum" lay-verify="required" /></div></td>' +

							'<td><div class="flex"><input  class="layui-input"  name="stock" lay-verify="required" /></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="sales"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="top_count"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="num"/></div></td>' +

							'<td><div class="flex"><input  class="layui-input"  name="duration"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="launch_fee"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="direct_fee"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="indirect_fee"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="leader_fee"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="team_fee"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="copartner_fee"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="station_fee"/></div></td>' +
							'<td><div class="flex"><input  class="layui-input"  name="oid" value=' + (a + i) +
							' /></div></td>' +
							'</tr>';
					}

					$('#temp').before(html)
				}

				window.choosedata = function() {
					layer.open({
						type: 2,
						title: '选择',
						shadeClose: false,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['100%', '100%'],
						content: 'list.html',
						end: function() {},
						success: function() {}
					});
				}

				// 重新计算
				window.resetNum = function() {
					if (tempObj.name) {
						var testtable = document.getElementById('testtable');
						var rows = testtable.rows;
						let list = []
						for (let i = 0; i < rows.length; i++) {
							let cells = rows[i].cells
							list.push($(cells))
						}
						delete list[0]
						delete list[list.length - 1]

						let array = list
						// console.log(array.length)
						if (array.length <= 2) {
							layer.msg('请先添加商品')
						} else {
							layer.confirm('确定要重新计算?', function() {
								layer.closeAll()
								for (let i = 0; i < array.length; i++) {
									if (array[i] !== undefined) {
										// console.log(array[i], 'array[i]')
										let price = array[i].find('input[name=price]').val()
										if (!price) {
											// console.log('没有输入团购价,无法重新计算')
											let skuid = array[i].find('input[name=skuid]').val()
											layer.msg(`请输入商品编号为${skuid}的团购价,重新点击按钮`)
											// break;
										} else {
											// 输入了团购价 重新计算 输入团人数
											let group_num = array[i].find('input[name=group_num]').val()
											if (!group_num) {
												// 没有输入团人数
												recalculate(array[i])
											} else {
												// 输入了团人数
												recalculate2(array[i])
											}
										}
									}
								}
							})
						}
					} else {
						layer.msg('请先选择模板')
					}
				}


				// 重新计算 没有输入团人数
				function recalculate(obj) {
					let price = $(obj).find("input[name=price]").val()
					price = parseInt(price)
					let launch_fee = getBili(tempObj.launch_fee, price) // 发起者奖励%
					let leader_fee = getBili(tempObj.leader_fee, price) // 团长奖励%
					let team_fee = getBili(tempObj.team_fee, price) // 团队奖励%
					let indirect_fee = getBili(tempObj.indirect_fee, price) // 间推奖励%
					let direct_fee = getBili(tempObj.direct_fee, price) // 直推奖励%
					let copartner_fee = getBili(tempObj.copartner_fee, price) // 合伙人奖励%
					let station_fee = getBili(tempObj.station_fee, price) // 服务站奖励%
					$(obj).find("input[name=launch_fee]").val(launch_fee)
					$(obj).find("input[name=leader_fee]").val(leader_fee)
					$(obj).find("input[name=team_fee]").val(team_fee)
					$(obj).find("input[name=indirect_fee]").val(indirect_fee)
					$(obj).find("input[name=direct_fee]").val(direct_fee)
					$(obj).find("input[name=copartner_fee]").val(copartner_fee)
					$(obj).find("input[name=station_fee]").val(station_fee)
				}

				// 重新计算 输入了团人数
				function recalculate2(obj) {
					// 先算没有输入团人数的钱
					let price = $(obj).find("input[name=price]").val()
					price = parseInt(price)
					let launch_fee = getBili(tempObj.launch_fee, price) // 发起者奖励%
					let leader_fee = getBili(tempObj.leader_fee, price) // 团长奖励%
					let team_fee = getBili(tempObj.team_fee, price) // 团队奖励%
					let indirect_fee = getBili(tempObj.indirect_fee, price) // 间推奖励%
					let direct_fee = getBili(tempObj.direct_fee, price) // 直推奖励%
					let copartner_fee = getBili(tempObj.copartner_fee, price) // 合伙人奖励%
					let station_fee = getBili(tempObj.station_fee, price) // 服务站奖励%
					let group_num = $(obj).find("input[name=group_num]").val()
					// 再算输入了团人数的钱
					$(obj).find("input[name=launch_fee]").val(getT(getBili(tempObj.launch_fee, price), group_num))
					$(obj).find("input[name=leader_fee]").val(getT(getBili(tempObj.leader_fee, price), group_num))
					$(obj).find("input[name=team_fee]").val(getT(getBili(tempObj.team_fee, price), group_num))
					$(obj).find("input[name=indirect_fee]").val(getT(getBili(tempObj.indirect_fee, price), group_num))
					$(obj).find("input[name=direct_fee]").val(getT(getBili(tempObj.direct_fee, price), group_num))
					$(obj).find("input[name=copartner_fee]").val(getT(getBili(tempObj.copartner_fee, price), group_num))
					$(obj).find("input[name=station_fee]").val(getT(getBili(tempObj.station_fee, price), group_num))
				}

				window.opentemp = function() {
					// alert('打开模板')
					temp.style.display = 'block'
					// 获取模板
					// layer.open({
					// 	type: 2,
					// 	title: '选择',
					// 	shadeClose: false,
					// 	shade: 0.5,
					// 	maxmin: true,
					// 	area: ['800px', '98%'],
					// 	content: '../../seckill_feetemp/list.html',
					// 	end: function() {},
					// 	success: function() {}
					// })
				}

				window.searchdata = function(type) {
					switch (type) {
						case 'skuid':
							layer.open({
								type: 2,
								title: '选择',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['800px', '98%'],
								content: 'choose_skuid.html',
								end: function() {},
								success: function() {}
							});
							break;
						case 'market_id':
							layer.open({
								type: 2,
								title: '选择',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['800px', '90%'],
								content: 'choose_limited.html',
								end: function() {},
								success: function() {}
							});
							break;
					}
				}

			});
			$(document).on('blur', "input[name=price]", function(e) {
				var tr = e.currentTarget.parentElement.parentElement.parentElement
				// layer.confirm('是否使用模板?',function(){
				// 	layer.closeAll('dialog');
				// 	if (tempObj.name) {
				// 		layer.msg(`当前使用模板:${tempObj.name}`)
				// 		let price = $(tr).find("input[name=price]").val()
				// 		price = parseInt(price)
				// 		console.log(price, '输入的价格')
				// 		let launch_fee = getBili(tempObj.launch_fee, price) // 发起者奖励%
				// 		let leader_fee = getBili(tempObj.leader_fee, price) // 团长奖励%
				// 		let team_fee = getBili(tempObj.team_fee, price) // 团队奖励%
				// 		let indirect_fee = getBili(tempObj.indirect_fee, price) // 间推奖励%
				// 		let direct_fee = getBili(tempObj.direct_fee, price) // 直推奖励%
				// 		let copartner_fee = getBili(tempObj.copartner_fee, price) // 合伙人奖励%
				// 		console.log(launch_fee, '发起者奖励')
				// 		$(tr).find("input[name=launch_fee]").val(launch_fee)
				// 		$(tr).find("input[name=leader_fee]").val(leader_fee)
				// 		$(tr).find("input[name=team_fee]").val(team_fee)
				// 		$(tr).find("input[name=indirect_fee]").val(indirect_fee)
				// 		$(tr).find("input[name=direct_fee]").val(direct_fee)
				// 		$(tr).find("input[name=copartner_fee]").val(copartner_fee)
				// 	} else {
				// 		$(tr).find("input[name=price]").val('')
				// 		layer.msg('请先选择模板');
				// 	}
				// },function(){
				// 	layer.msg('取消操作');
				// })
				if (tempObj.name) {
					if (!$(tr).find("input[name=price]").val()) {
						$(tr).find("input[name=launch_fee]").val('')
						$(tr).find("input[name=leader_fee]").val('')
						$(tr).find("input[name=team_fee]").val('')
						$(tr).find("input[name=indirect_fee]").val('')
						$(tr).find("input[name=direct_fee]").val('')
						$(tr).find("input[name=copartner_fee]").val('')
						$(tr).find("input[name=station_fee]").val('')
					} else {
						let price = $(tr).find("input[name=price]").val()
						price = parseInt(price)
						console.log(price, '输入的价格')
						let launch_fee = getBili(tempObj.launch_fee, price) // 发起者奖励%
						let leader_fee = getBili(tempObj.leader_fee, price) // 团长奖励%
						let team_fee = getBili(tempObj.team_fee, price) // 团队奖励%
						let indirect_fee = getBili(tempObj.indirect_fee, price) // 间推奖励%
						let direct_fee = getBili(tempObj.direct_fee, price) // 直推奖励%
						let copartner_fee = getBili(tempObj.copartner_fee, price) // 合伙人奖励%
						let station_fee = getBili(tempObj.station_fee, price) // 服务站奖励%
						console.log(launch_fee, '发起者奖励')
						$(tr).find("input[name=launch_fee]").val(launch_fee)
						$(tr).find("input[name=leader_fee]").val(leader_fee)
						$(tr).find("input[name=team_fee]").val(team_fee)
						$(tr).find("input[name=indirect_fee]").val(indirect_fee)
						$(tr).find("input[name=direct_fee]").val(direct_fee)
						$(tr).find("input[name=copartner_fee]").val(copartner_fee)
						$(tr).find("input[name=station_fee]").val(station_fee)
					}
				} else {

				}
			})



			$(document).on('keyup', "input[name=group_num]", function(e) {
				var tr = e.currentTarget.parentElement.parentElement.parentElement
				if (!$(tr).find("input[name=price]").val()) {
					layer.msg('请先输入团购价')
					$(tr).find("input[name=group_num]").val('')
				} else if (tempObj.id !== undefined) {
					if (!$(tr).find("input[name=group_num]").val()) {
						// 重新计算比例
						console.log('重新计算比例')
						let price = $(tr).find("input[name=price]").val()
						price = parseInt(price)
						console.log(price, '输入的价格')
						let launch_fee = getBili(tempObj.launch_fee, price) // 发起者奖励%
						let leader_fee = getBili(tempObj.leader_fee, price) // 团长奖励%
						let team_fee = getBili(tempObj.team_fee, price) // 团队奖励%
						let indirect_fee = getBili(tempObj.indirect_fee, price) // 间推奖励%
						let direct_fee = getBili(tempObj.direct_fee, price) // 直推奖励%
						let copartner_fee = getBili(tempObj.copartner_fee, price) // 合伙人奖励%
						let station_fee = getBili(tempObj.station_fee, price) // 服务站奖励%
						console.log(launch_fee, '发起者奖励')
						$(tr).find("input[name=launch_fee]").val(launch_fee)
						$(tr).find("input[name=leader_fee]").val(leader_fee)
						$(tr).find("input[name=team_fee]").val(team_fee)
						$(tr).find("input[name=indirect_fee]").val(indirect_fee)
						$(tr).find("input[name=direct_fee]").val(direct_fee)
						$(tr).find("input[name=copartner_fee]").val(copartner_fee)
						$(tr).find("input[name=station_fee]").val(station_fee)
					} else {
						// 填写完团人数重新计算
						let price = $(tr).find("input[name=price]").val()
						price = parseInt(price)
						let launch_fee = $(tr).find("input[name=launch_fee]").val()
						let leader_fee = $(tr).find("input[name=leader_fee]").val()
						let team_fee = $(tr).find("input[name=team_fee]").val()
						let indirect_fee = $(tr).find("input[name=indirect_fee]").val()
						let direct_fee = $(tr).find("input[name=direct_fee]").val()
						let copartner_fee = $(tr).find("input[name=copartner_fee]").val()
						let station_fee = $(tr).find("input[name=station_fee]").val()
						let group_num = $(tr).find("input[name=group_num]").val()
						$(tr).find("input[name=launch_fee]").val(getT(getBili(tempObj.launch_fee, price), group_num))
						$(tr).find("input[name=leader_fee]").val(getT(getBili(tempObj.leader_fee, price), group_num))
						$(tr).find("input[name=team_fee]").val(getT(getBili(tempObj.team_fee, price), group_num))
						$(tr).find("input[name=indirect_fee]").val(getT(getBili(tempObj.indirect_fee, price), group_num))
						$(tr).find("input[name=direct_fee]").val(getT(getBili(tempObj.direct_fee, price), group_num))
						$(tr).find("input[name=copartner_fee]").val(getT(getBili(tempObj.copartner_fee, price),
							group_num))
						$(tr).find("input[name=station_fee]").val(getT(getBili(tempObj.station_fee, price), group_num))
					}
				}
			})

			function getBili(num1, num2) {
				// let num = 0
				// if (num2 == 100) {
				// 	num = (Math.round(num1/num2 * 10000) / 100.00);
				// } else {
				// 	num = (Math.round(num1/num2 * 100) / 100.00);
				// }
				let num = Math.round(num1 * num2) / 100
				return num.toFixed(2)
			}

			function getT(num1, num2) {
				let num = num1 / num2
				return num.toFixed(2)
			}
			//			$(document).on("blur","input[name=score]",function(e){
			//				var tr = e.currentTarget.parentElement.parentElement.parentElement
			//				console.log(tr)				
			//				var market_price = $(tr).find("input[name=price]").val()
			//				var score = $(tr).find("input[name=score]").val()
			//				if (score> 0 && market_price>0) {
			//					var sumprice_member = Math.round(parseFloat(market_price) * 100) / 100
			//					var sumScore = Math.round(parseFloat(score) * 100) / 100 
			//					var sumScale = Math.round(parseFloat((sumScore/market_price).toFixed(2)) * 100)  
			//					$(tr).find("input[name=score_scale]").val(sumScale)
			//				}
			//			})
			//			
			//			$(document).on("blur","input[name=score_scale]",function(e){
			//				
			//				var tr = e.currentTarget.parentElement.parentElement.parentElement
			//				console.log(tr)				
			//				var market_price = $(tr).find("input[name=price]").val()
			//				var score_scale = $(tr).find("input[name=score_scale]").val()
			//				if (score_scale >0 &&  score_scale <=100 && market_price>0 ) {
			//					var sumScore = Math.round(parseFloat((market_price*score_scale).toFixed(2)) * 100) /10000
			//					$(tr).find("input[name=score]").val(sumScore)
			//				}
			//			})
		</script>
	</body>

</html>
